package com.gt.quality.system.entity.vo;

import com.gt.quality.system.entity.SysMenu;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

/**
 * 万里悲秋常作客,百年多病独登台
 *
 * @author : makeJava
 */
@Data
public class TreeTableMenuVo implements Serializable {

    private String id;

    private String parentId;

    private String routePath;

    private String icon;

    private String name;

    private String compontPath;

    private String isShow;

    private String sort;

    private String type;

    private String perms;

    public SysMenu buildConvertDto() {
        SysMenu sysMenu = new SysMenu();
        sysMenu.setMenuId(StringUtils.isNotBlank(this.getId()) ? Long.parseLong(this.getId()) : null);
        sysMenu.setParentId(StringUtils.isNotBlank(this.getParentId()) ? Long.parseLong(this.getParentId()) : null);
        sysMenu.setComponent(this.getCompontPath());
        sysMenu.setPath(this.getRoutePath());
        sysMenu.setIcon(this.getIcon());
        sysMenu.setMenuName(this.getName());
        sysMenu.setVisible("显示".equals(this.getIsShow()) ? "0" : "1");
        sysMenu.setOrderNum(Integer.valueOf(this.getSort()));
        sysMenu.setPerms(this.getPerms());
        sysMenu.setIsFrame("F".equals(this.getType()) ? 1 : 0);
        // （M目录 C菜单 F外链
        sysMenu.setMenuType(this.getType());
        sysMenu.setTenantId("0");
        sysMenu.setRemark(this.getName() + "-菜单");
        return sysMenu;
    }
}
